package runnables;

import log.Logger;
import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import screens.Controller;
import strings.WebcampusResource;
import test.GradeAnalyzer;

public class DesSuscribirPushRunnable implements Runnable, WebcampusResource{

	// RESOURCES
	private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);

	public DesSuscribirPushRunnable(){
	}

	public void run() {

		GradeAnalyzer ga = GradeAnalyzer.getInstance();
		try{
			// hash , pin
			ga.desSuscribirPush(Controller.getInstance().getHash(),Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase());
			//System.out.println(Integer.toHexString(DeviceInfo.getDeviceId()).toUpperCase()+" ************* pin ");
		} catch (Exception e){
			Logger.log("dessuscribir push error");
		}

		//if everything is ok, do:
		UiApplication.getUiApplication().invokeLater(new Runnable() {
			public void run() {
				if (Controller.getInstance().getPushStatus())
					Dialog.inform(resources.getString(ALERT_PUSH_UNSUSC_FAIL));
				else {// false 
					Dialog.inform(resources.getString(ALERT_PUSH_UNSUSC_OK));
				}
			}
		});
	}


}
